package Netzwerkprogrammierung.g3.Sockets;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class SimpleTCPServer {

	public static void main(String[] args) throws IOException {
		ServerSocket server = new ServerSocket(1234);
		
		//Client:
		//Socket s = new Socket("127.0.0.1",1234);

		Socket socket = server.accept();

		InputStream in = socket.getInputStream();
		BufferedReader reader = new BufferedReader(new InputStreamReader(in));
		
		String clientToServer = reader.readLine();
		String serverToClient = clientToServer.toUpperCase();
		
		OutputStream out = socket.getOutputStream();
		BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out));
		
		writer.write(serverToClient);
		writer.newLine();
		
		reader.close();
		writer.close();
		
		socket.close();
		
	}

}
